package com.i8office.android.zhihuixinwu.module.presenter;

import com.cyan.tools.callback.SimpleCallback;
import com.i8office.android.zhihuixinwu.module.contract.OpinionContract;
import com.i8office.android.zhihuixinwu.module.model.OpinionModel;

import java.util.ArrayList;

/**
 * Created by pc on 2018/7/7.
 */

public class OpinionPresenter extends BasePresenterImpl<OpinionContract.View> implements OpinionContract.Presenter {
    OpinionContract.Model model;
    public OpinionPresenter(OpinionContract.View view) {
        super(view);
        model=new OpinionModel();
    }

    @Override
    public void getPublicOpinion() {
        addDisposable(model.getPublicOpinion(new SimpleCallback<ArrayList<String>>(mView){
            @Override
            public void requestSuccess(ArrayList<String> data){
                mView.showResult(data);
            }

            @Override
            public void requestError(String msg) {
                super.requestError(msg);
                mView.showError();
            }
        }));
    }

    @Override
    public void getPrivateOpinion() {
        model.getPrivateOpinion(new SimpleCallback<ArrayList<String>>(mView){
            @Override
            public void requestSuccess(ArrayList<String> data){
                mView.showResult(data);
            }

            @Override
            public void requestError(String msg) {
                super.requestError(msg);
                mView.showError();
            }
        });
    }
}
